﻿<Page
    x:Class="FunstreamTV.ClientPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    DataContext="{Binding ClientViewModel, RelativeSource={RelativeSource Self}}"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton x:Uid="CancelAppButton" Icon="Cancel" Click="ResetCategory" Visibility="{Binding GoBackAppButtonVisibility}"/>
            <AppBarButton x:Uid="RefreshAppButton" Icon="Refresh" Click="RefreshClick"/>
            <CommandBar.SecondaryCommands>
                <AppBarButton x:Uid="LogoutAppButton" Click="LogoutClick"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
        
    </Page.BottomAppBar>
    <Grid x:Name="LayoutRoot">

        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <TextBlock x:Uid="AppName" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,12,0,0"/>
        </StackPanel>

        <Pivot Grid.Row="1" SelectionChanged="PivotItemSelected">
            <PivotItem x:Uid="ClientPageTopStreams">
                <ListView ItemsSource="{Binding TopStreams}" IsItemClickEnabled="True" ItemClick="StreamClick" >
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="10" Background="#70FFFFFF">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Source="{Binding FullImageUrl}" />
                                <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding name}" FontSize="25" TextWrapping="Wrap"/>
                                <TextBlock Grid.Row="2" Grid.Column="0" Text="{Binding streamer.name}" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding rating}" HorizontalAlignment="Right"/>
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </PivotItem>
            <PivotItem x:Uid="ClientPageFavorites">
                <ListView ItemsSource="{Binding FavoritesStreams}" IsItemClickEnabled="True" ItemClick="StreamClick">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="10" Background="#70FFFFFF">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Source="{Binding FullImageUrl}" />
                                <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding name}" FontSize="25" TextWrapping="Wrap"/>
                                <TextBlock Grid.Row="2" Grid.Column="0" Text="{Binding streamer.name}" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding rating}" HorizontalAlignment="Right"/>
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </PivotItem>
            <PivotItem x:Uid="ClientPageCategories">
                <Grid>
                    <ListView ItemsSource="{Binding Categories}" IsItemClickEnabled="True" ItemClick="CategoryClick" Visibility="{Binding CategoriesVisibility}">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Border Margin="10" Background="CornflowerBlue">
                                    <TextBlock Text="{Binding slug}" FontSize="30"/>
                                </Border>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                    <ListView ItemsSource="{Binding GroupedStreams}" IsItemClickEnabled="True" ItemClick="StreamClick" Visibility="{Binding GroupedStreamsVisibility}">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="10" Background="#70FFFFFF">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Image Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Source="{Binding FullImageUrl}" />
                                    <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding name}" FontSize="25" TextWrapping="Wrap"/>
                                    <TextBlock Grid.Row="2" Grid.Column="0" Text="{Binding streamer.name}" HorizontalAlignment="Left"/>
                                    <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding rating}" HorizontalAlignment="Right"/>
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </PivotItem>
        </Pivot>
    </Grid>
</Page>
